﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MissionEditor
{
    public partial class SelectConditionTypeDialog : Form
    {
        int conditionCode = -1;
        Dictionary<string, int> entries = new Dictionary<string, int>();

        public int ConditionCode
        {
            get { return conditionCode; }
        }


        public SelectConditionTypeDialog(int initialConditionCode)
        {
            conditionCode = initialConditionCode;
            InitializeComponent();

            entries.Add("BuildingExists", 0);
            entries.Add("UnitExists", 1);
            entries.Add("Interval", 2);
            entries.Add("Timer", 3);
            entries.Add("Casualties", 4);
            entries.Add("BaseDestroyed", 5);
            entries.Add("UnitsDestroyed", 6);
            entries.Add("Unit In Tile", 7);
            entries.Add("Cash", 8);
            entries.Add("DummyCondition", 9);

            int selectedIndex = -1;

            for (int i = 0; i < entries.Count; i++)
			{
                comboBox1.Items.Add(entries.ElementAt(i).Key);
                if (conditionCode == entries.ElementAt(i).Value)
                    selectedIndex = i;
			}
            comboBox1.SelectedIndex = selectedIndex;
                
        }

        private void button1_Click(object sender, EventArgs e)
        {
            conditionCode = entries[comboBox1.SelectedItem.ToString()];
            DialogResult = DialogResult.OK;
            Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }
    }
}
